//
//  C_RecentListCollectionViewCell.m
//  音悦咖
//
//  Created by Best on 15/7/23.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "C_RecentListCollectionViewCell.h"

@implementation C_RecentListCollectionViewCell

- (void)dealloc
{
    [_countLabel release];
    [_titleLabel release];
    [_typeView release];
    [_playView release];
    [super dealloc];
}


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self create];
    }
    return self;
}

- (void)create
{
    self.titleLabel = [[UILabel alloc] init];
    [self addSubview:self.titleLabel];
    [_titleLabel release];
    
    self.countLabel = [[UILabel alloc] init];
    [self addSubview:self.countLabel];
    [_countLabel release];
    
    self.typeView = [[UIImageView alloc] init];
    [self addSubview:self.typeView];
    [_typeView release];
    
    self.playView = [[UIImageView alloc] init];
    [self addSubview:self.playView];
    [_playView release];
    
    
}

-(void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    
    
//    self.backgroundColor = RGBA(180, 180, 180, 0.8);
    self.titleLabel.frame = CGRectMake(40, 0, SCREEN_WIDTH - 80, 30);
    self.titleLabel.textColor = WHITE;
    self.countLabel.frame = CGRectMake(self.titleLabel.frame.origin.x + 10, layoutAttributes.frame.size.height - 25, self.titleLabel.frame.size.width, 20);
    self.countLabel.textColor = WHITE;
    self.typeView.frame = CGRectMake(5, 10, 30, layoutAttributes.frame.size.height - 20);
    self.typeView.image = [UIImage imageWithContentsOfFile:GETBUNDLE_PATH(@"typepic@2x", @"png")];
    self.playView.frame = CGRectMake(layoutAttributes.frame.size.width - 50, 10, 40, layoutAttributes.frame.size.height - 20);
    self.playView.image = [UIImage imageWithContentsOfFile:GETBUNDLE_PATH(@"playpic@2x", @"png")];
}

- (void)setModel:(C_RecentSkimModel *)model
{
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    
    self.titleLabel.text = model.title;
    self.countLabel.text = model.count;
}


@end
